<template>
  <div class="input-section">
    <el-form>
      <el-form-item label="用户ID列表">
        <el-input
          v-model="userIdInput"
          type="textarea"
          :rows="5"
          placeholder="请输入用户ID，每行一个"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="startProcess" :loading="processing">开始批量处理</el-button>
        <el-button @click="clearInput" :disabled="processing">清空输入</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup lang="ts">
import { ref, defineEmits } from 'vue'

const props = defineProps<{
  processing: boolean
}>()

const emit = defineEmits<{
  'start-process': [userIds: string[]]
  'clear-results': []
}>()

const userIdInput = ref('')

const startProcess = () => {
  if (!userIdInput.value.trim()) {
    return
  }
  
  // 解析用户ID列表
  const userIds = userIdInput.value.split('\n')
    .map(id => id.trim())
    .filter(id => id !== '')
  
  emit('start-process', userIds)
}

const clearInput = () => {
  userIdInput.value = ''
  emit('clear-results')
}
</script>

<style scoped>
.input-section {
  margin-bottom: 20px;
}
</style>